package leetcode.code206.ReverseLinkedList;

import leetcode.IDebug;
import leetcode.helper.tree.ListNode;

public class Solution20601 extends ReverseLinkedList {

	@Override
	public ListNode reverseList(ListNode head) {
		if (head == null || head.next == null)
			return head;
		ListNode p = head.next;
		ListNode temp = null;
		head.next = null;
		while (p != null) {
			temp = p;
			p = p.next;
			temp.next = head;
			head = temp;
		}
		return head;
	}

	public static void main(String[] args) {
		IDebug i = new Solution20601();
		i.debug1();
		i.debug2();
		i.debug3();
	}

}
